package com.csc.contact.checkbill.controller;

import com.csc.contact.checkbill.kafkaconfig.KafkaProducer;
import com.csc.contact.checkbill.service.*;
import com.csc.contact.checkbill.task.MyTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA
 *
 * @auther zhanglei
 * @date 2019/7/12 18:10
 * Description: 初始化操作
 */
@Component
@Order(1)
public class CheckBillApplicationRunner implements ApplicationRunner {
    @Resource(name = "reconciliationservice")
    private ReconciliationServiceImpl reconciliationService;

    @Resource(name = "urpchargeinfoService")
    private UrpChargeinfoServiceImpl urpChargeinfoService;
    @Resource(name = "checklogService")
    private CheckLogServiceImpl checklogService;

    @Resource(name = "kafkaConfig")
    private KafkaProducer kafkaProducer;

    @Resource(name = "checkdiffservice")
    private CheckDiffServiceImpl checkDiffService;

    @Resource(name = "urpprovinceservice")
    private UrpProvinceinfoServiceImpl urpProvinceinfoService;

    private static final Logger logger = LoggerFactory.getLogger(CheckBillApplicationRunner.class);

    @Override
    public void run(ApplicationArguments applicationArguments) {
        logger.info("开始对账================>>>>>>>>>>>");
        String time = "00:00:00";
        new MyTask().fixedRate(time, new ReadFileFromFTPTask(reconciliationService, urpChargeinfoService, checklogService,
                checkDiffService,urpProvinceinfoService,kafkaProducer));

    }
}
